package com.gitee.ed.arithmetic.leetcode.answer.answer_1_100.answer_11_20;

import com.gitee.ed.arithmetic.leetcode.solution.solution_1_100.solution_11_20.Solution11;

/**
 * 双指针
 *
 * @author hongda.li
 */
public class Answer11 implements Solution11 {
    @Override
    public int maxArea(int[] height) {
        int result = 0;

        int left = 0;
        int right = height.length - 1;

        while (left != right) {
            result = Math.max(result, Math.min(height[left], height[right]) * (right - left));
            if (height[left] < height[right]) {
                left++;
            } else {
                right--;
            }
        }

        return result;
    }
}
